package com.company;

import com.company.adapterMode.AudioPlayer;
import com.company.bridgeMode.Circle;
import com.company.bridgeMode.GreenCircle;
import com.company.bridgeMode.RedCircle;
import com.company.bridgeMode.Shape;
import com.company.strategyMode.Context;
import com.company.strategyMode.OperationAdd;
import com.company.strategyMode.OperationMultiply;
import com.company.strategyMode.OperationSubtract;

public class Main {

    public static void main(String[] args) {
        //适配器模式 DesignPatternLearning
//        AudioPlayer audioPlayer = new AudioPlayer();
//        audioPlayer.play("mp3", "beyond the horizon.mp3");
//        audioPlayer.play("mp4", "alone.mp4");
//        audioPlayer.play("vlc", "far far away.vlc");
//        audioPlayer.play("avi", "mind me.avi");
        //桥接模式
        //使用 Shape 和 DrawAPI 类画出不同颜色的圆
//        Shape redCircle = new Circle(100,100, 10, new RedCircle());
//        Shape greenCircle = new Circle(100,100, 10, new GreenCircle());
//        redCircle.draw();
//        greenCircle.draw();
        //策略模式
        //使用 Context 来查看当它改变策略 Strategy 时的行为变化
        Context context = new Context(new OperationAdd());
        System.out.println("10 + 5 = " + context.executeStrategy(10, 5));

        context = new Context(new OperationSubtract());
        System.out.println("10 - 5 = " + context.executeStrategy(10, 5));

        context = new Context(new OperationMultiply());
        System.out.println("10 * 5 = " + context.executeStrategy(10, 5));
    }
}
